package com.jn.dagger.views;

import android.util.Log;

import com.jn.dagger.R;
import com.jn.dagger.application.MyApplication;
import com.jn.dagger.base.BaseActivity;
import com.jn.dagger.database.DBHelper;
import com.jn.dagger.entity.Course;
import com.jn.dagger.entity.Student;
import com.jn.dagger.utils.SpUtils;

import java.util.List;

import jakarta.inject.Inject;

public class InfoActivity extends BaseActivity {
    @Inject
    public Student mStudent;
    private Course mcourse;
    @Inject
    public DBHelper mDBHelper;
    @Inject
    public SpUtils mSpUtils;
    @Override
    public int getLayoutId() {
        return R.layout.activity_info;
    }

    @Override
    public void init() {
        ((MyApplication)getApplication()).getAllComponent().injectInfoActivity(this);

        List<Student> list = mDBHelper.selectAllStudents();
        List<Course> list1 = mDBHelper.selectAllCourses();

        int size = list.size();
        if (size > 0) {
            mStudent = list.get(size - 1);
            Log.d("asdf", mStudent.toString());
        } else {
            Log.d("asdf", "list is empty");
        }

        int size1 = list1.size();
        if (size1 > 0) {
            mcourse = list1.get(size1 - 1);
            Log.d("asdf", mcourse.toString());
        } else {
            Log.d("asdf", "list1 is empty");
        }

        Log.d("asdf", mSpUtils.getString("key"));
    }
}